package com.example.androidhive;

import java.util.regex.Matcher;
import java.util.regex.Pattern;

import org.json.JSONException;
import org.json.JSONObject;

public class Wynik {
	
	public static boolean zamien0i1(String znacznik,String a){
		String[] d=a.split(",");
		boolean c=false;
		for (int i = 0; i < d.length; i++) {
			d[i]=d[i].replace("\"", "");
			String[] y=d[i].split(":");
			if (y[0].equals(znacznik)){
				c=(y[1].equals("0"))?true:false;}
		}
		return c;
	}
	public static void wsp(){
		JSONObject a =Wynik.json;String _x="",_y="";
		try {
			_y=_x=null;
			_x =(String) Wynik.json.get("x").toString();
			_y =(String) Wynik.json.get("y").toString();
			String c="";
		} catch (JSONException e) {
			e.printStackTrace();
		}
		 Pattern pattern = Pattern.compile("[{]{1}.*[}]{1}");
		    // in case you would like to ignore case sensitivity,
		    // you could use this statement:
		    // Pattern pattern = Pattern.compile("\\s+", Pattern.CASE_INSENSITIVE);
		    Matcher matcher = pattern.matcher(_x);
		    // check all occurance
		    while (matcher.find()) {
		      System.out.print("Start index: " + matcher.start());
		      System.out.print(" End index: " + matcher.end() + " ");
		      System.out.println(matcher.group());
		      String z=matcher.group();
		    }
			//h=h.replace("},{", "!");
			/*h=h.replace("{", "");
			h=h.replace("}", "");
			h=h.replace("[", "");*/
		//{"success":1,"y":[{"yid2":null,"yy":"4.416623935103416","yid":"1"},{"yid2":null,"yy":"14.43600967526436","yid":"2"},{"yid2":null,"yy":"22.86536581814289","yid":"3"},{"yid2":null,"yy":"15.836549922823904","yid":"4"},{"yid2":null,"yy":"19.726738035678864","yid":"5"},{"yid2":null,"yy":"19.73786987364292","yid":"6"}],"x":[{"xid":"1","xx":"7.168966287562862","xid2":null},{"xid":"2","xx":"50.29196905635706","xid2":null},{"xid":"3","xx":"53.25659076376557","xid2":null},{"xid":"4","xx":"49.136871552764845","xid2":null},{"xid":"5","xx":"51.978961025301224","xid2":null},{"xid":"6","xx":"53.91784891162862","xid2":null}]}
	}
	static JSONObject json;
	public static int wynik=0;
	public static Wynik instancja=new Wynik();
	public static Wynik get(){
		if(instancja==null)
			return instancja=new Wynik();
		else
			return instancja;
	}
}
